package net.sxnic.workflow.pi;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import net.sxinfo.core.entity.AbstractEntity;
import net.sxnic.workflow.pd.Pd;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 * process instance 流程实例表，每个业务即每个公文都对应一个流程实例
 * @author 孙宇飞
 *
 */
@Entity
@Table(name = "wf_pi")
@BatchSize(size = 10)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Pi extends AbstractEntity {

	private static final long serialVersionUID = 2292294294985184883L;

	public static final String PROCESS_STATUS_ACTIVE = "active";

	public static final String PROCESS_STATUS_END = "end";	

	/**
	 * 流程的结束时间 可有可无
	 */
	private Date endDate;

	/**
	 * 流程的名字
	 */
	private String processName;

	/**
	 * 本次流程对应实体的Title
	 */
	private String title;

	/**
	 * 本次流程发起人的所在部门
	 */
	private String dept;

	/**
	 * 本次流程对应实体的Id
	 */
	private String entityId;

	/**
	 * 任务办理情况，所有任务都办完=办结，其他=未办结
	 */
	private boolean allTaskDealed;

	/**
	 * 领导办理情况。收文的“领导批阅”，发文的“领导签发”，“领导转签”
	 */
	private boolean leaderDealed;
	
	@ManyToOne
	@Cascade(value = { CascadeType.REFRESH})
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)	
	private Pd pd;	

	public Pi() {
		super();		
	}

	public Pi(String processName, String title, String dept, String entityId,
			Pd pd) {
		super();
		this.processName = processName;
		this.title = title;
		this.dept = dept;
		this.entityId = entityId;
		this.pd = pd;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public String getProcessName() {
		return processName;
	}

	public void setProcessName(String processName) {
		this.processName = processName;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDept() {
		return dept;
	}

	public void setDept(String dept) {
		this.dept = dept;
	}

	public String getEntityId() {
		return entityId;
	}

	public void setEntityId(String entityId) {
		this.entityId = entityId;
	}

	public boolean isAllTaskDealed() {
		return allTaskDealed;
	}

	public void setAllTaskDealed(boolean allTaskDealed) {
		this.allTaskDealed = allTaskDealed;
	}

	public boolean isLeaderDealed() {
		return leaderDealed;
	}

	public void setLeaderDealed(boolean leaderDealed) {
		this.leaderDealed = leaderDealed;
	}

	public Pd getPd() {
		return pd;
	}

	public void setPd(Pd pd) {
		this.pd = pd;
	}
}
